package ieco.domaine;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;

@Entity
@Table(schema = "OPTIONS", name = "OPTIONS")
//@SequenceGenerator(schema = "OPTIONS", name = "SEQ_OPTION", sequenceName = "OPTIONS_ID_SEQ")
@SuppressWarnings("serial")
public class Option implements Serializable {

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	private int id;

	@NotNull
	@Column(name = "code")
	private String code;

	@Column(name = "intitule", nullable = true)
	private String intitule;

	@NotNull
	@Column(name = "ects")
	private double ects;

	@NotNull
	@Column(name = "annee_debut")
	private int annee_debut;

	@Column(name = "annee_fin", nullable = true)
	private int annee_fin;

	// Constructeur vide
	public Option() {
	}

	// Constructeur reprenant les champs not nulls
	public Option(String code, double ects, int annee_debut) {
		super();
		this.code = code;
		this.ects = ects;
		this.annee_debut = annee_debut;
	}

	// Constructeur complet
	public Option(String code, String intitule, double ects, int annee_debut,
			int annee_fin) {
		super();
		this.code = code;
		this.intitule = intitule;
		this.ects = ects;
		this.annee_debut = annee_debut;
		this.annee_fin = annee_fin;
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public String getIntitule() {
		return intitule;
	}

	public void setIntitule(String intitule) {
		this.intitule = intitule;
	}

	public double getEcts() {
		return ects;
	}

	public void setEcts(double ects) {
		this.ects = ects;
	}

	public int getAnnee_debut() {
		return annee_debut;
	}

	public void setAnnee_debut(int annee_debut) {
		this.annee_debut = annee_debut;
	}

	public int getAnnee_fin() {
		return annee_fin;
	}

	public void setAnnee_fin(int annee_fin) {
		this.annee_fin = annee_fin;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + id;
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Option other = (Option) obj;
		if (id != other.id)
			return false;
		return true;
	}

}
